package com.example.rpc_easy.register;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;


public class LocalRegister {
    /**
     * 注册信息储存
     */
    private static final Map<String, Class<?>> registerMap = new ConcurrentHashMap<>();

    /**
     * 注册服务
     * @param ServicesName
     * @param impClass
     */
    public static void register(String ServicesName, Class<?> impClass) {
        System.out.println("请求服务名: " + ServicesName);
        System.out.println("获取到的类: " + impClass);
        registerMap.put(ServicesName, impClass);

    }

    /**
     * 获取服务
     * @param ServicesName
     * @return
     */
    public static Class<?>get(String ServicesName){
        return registerMap.get(ServicesName);
    }

    /**
     * 移除服务
     * @param servicesName
     */
    public static void remove(String servicesName){
        registerMap.remove(servicesName);
    }
}